********************************************************************************
*
**# Fig 5: Total Number of monthly DV charges vs Assault charges
*
********************************************************************************

* 	Load court records filed in Davidson County court: 

use  "${DATA}/cjis.dta", clear 

* 	Keep male defendants:

drop if missing(female) 

keep if female == 0 

* 	Keep years 2000 to 2015:

drop if year_court < 2000	
drop if year_court > 2015 

* 	Keep misdemeanor records in the general sessions:

keep if casetype 		== "gs" 
keep if any_felony 		== 0 
drop if charged_offense == "assault of officer" 

keep dv_case aslt_nondom_case year_court def_id date_court judge courtroom 

* 	Collapse to case level (vs charge level)

gsort def_id date_court judge courtroom  -dv_case 

by def_id date_court judge courtroom, sort: keep if _n == 1 

collapse (sum) dv_case aslt_nondom_case, by(year_court) 

* 	for graph label 

qui sum year_court 
gen lab_dv = "DV" 		 if year_court==r(max) 
gen lab_aslt = "Assault" if year_court==r(max) 
	
* 	graph options 
# d ; 

local lab_opts 
	"lcolor(black) lwidth(medthick) 
	 msize(small) mcolor(black)
	  msize(zero) mlabsize(medium) mlabcolor(black)"	;
	  
local spk_opts
	"lpattern(dot) lcolor(gs7) lwidth(thin)" ;
	  
/* fig 5 */

graph twoway 
	(connected dv_case year_court , mlab(lab_dv) `lab_opts') 
	(spike dv_case year_court if year_court > 2001 , `spk_opts')
	(spike aslt_nondom_case year_court if year_court < 2002 , `spk_opts') 
	(connected aslt_nondom_case year_court, mlab(lab_aslt) `lab_opts' lpattern(dash)),
	xtitle("Year", margin(0 0 0 2.5))
	ytitle("")	
	xscale(range(1999.8 2017))
	yscale(range(0 1700)) 
	ylab(0(200)1600,angle(0) nogrid)
	xlab(2000(5)2015)
	xsize(24) ysize(18) 
	legend(off) ;
	
# d cr

graph save "${OUTPUT}/fig5.gph", replace  

********************************************************************************
*	End of File
********************************************************************************
